﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sealight.Core.Common;

namespace Sealight.Core.Domain
{
   public class ProductVariantAttributeEntity:BaseEntity
    {
        /// <summary>
        /// Gets or sets the product variant attribute mapping identifier
        /// </summary>
        public virtual Guid ProductVariantAttributeID { get; set; }
        /// <summary>
        /// Gets or sets a value a text prompt
        /// </summary>
        public virtual string TextPrompt { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether the entity is required
        /// </summary>
        public virtual bool IsRequired { get; set; }
        /// <summary>
        /// Gets or sets the attribute control type identifier
        /// </summary>
        public virtual AttributeControlType AttributeControlType { get; set; }
        /// <summary>
        /// Gets or sets the display order
        /// </summary>
        public virtual int DisplayOrder { get; set; }
        /// <summary>
        /// Gets or sets the product variant identifier
        /// </summary>
        public virtual ProductVariantEntity ProductVariant { get; set; }
        /// <summary>
        /// Gets or sets the product attribute identifier
        /// </summary>
        public virtual ProductAttributeEntity ProductAttribute { get; set; }

        public virtual IList<ProductVariantAttributeValueEntity> Values { get; set; }

        public virtual Sealight.Core.DataAdapter.product_variant_attribute ToDataAdapter()
        {
            DataAdapter.product_variant_attribute data=new DataAdapter.product_variant_attribute {id=this.ProductVariantAttributeID, attribute_control_type = this.AttributeControlType,
            display_order=this.DisplayOrder, is_required=this.IsRequired,text_prompt = this.TextPrompt
            };

            if (this.ProductVariant != null)
                data.product_variant = this.ProductVariant.ToDataAdapter();
            if (this.ProductAttribute != null)
                data.product_attribute = this.ProductAttribute.ToDataAdapter();
            if (this.Values != null)
                data.values = (from c in this.Values select c.ToDataAdapter()).ToList();

            return data;
        }
    }
}
